package org.interfaceadaptation.test.notnull;

import java.util.Arrays;
import java.util.Collection;
import java.util.Date;

import org.joda.time.LocalDate;
import org.joda.time.LocalDateTime;
import org.joda.time.LocalTime;

public class FinalVerifier implements Verifier {

	Collection<Class<?>> finalClasses = Arrays.asList(new Class<?>[] {
			String.class, Date.class, LocalDate.class, LocalDateTime.class,
			LocalTime.class, Boolean.class, Byte.class, Short.class,
			Integer.class, Long.class, Double.class, boolean.class, byte.class,
			short.class, int.class, long.class, double.class });

	@Override
	public boolean verify(Object element) {
		if (isVerifyerFor(element)) {
			if (element == null) {
				throw new AssertionDeepNotNullError();
			} else {
				return true;
			}
		} else {
			return false;
		}
	}
	
	private boolean isVerifyerFor(Object element) {
		if (element == null) {
			return true;
		}
		for (Class<?> finalClass : finalClasses) {
			if (finalClass.isAssignableFrom(element.getClass())) {
				return true;
			}
		}
		return false;
	}



}
